Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

321
Visualizações
"GUILD" intent throwing error (discord.js)

i am trying to make a discord bot but when i use this code i get an error. please help, as i do not understand!

EDIT: i just attached the error, you're welcome!

code:

const Discord = require('discord.js');
const client = new Discord.Client({
    allowedMentions: {
        parse: ['users', 'roles'],
        repliedUser: true
    },
    intents: [
        "GUILDS",
        "GUILD_MESSAGES",
        "GUILD_PRESENCES",
        "GUILD_MEMBERS",
        "GUILD_MESSAGE_REACTIONS"
    ],
});
client.on('ready', () => {
    console.log('I am ready')
});
client.login("TOKEN")

error is:

C:\Users\me\OneDrive\Desktop\code\js\my bot\node_modules\discord.js\src\util\BitField.js:168
    throw new RangeError(ErrorCodes.BitFieldInvalid, bit);
    ^

RangeError [BitFieldInvalid]: Invalid bitfield flag or number: GUILDS.
    at Function.resolve (C:\Users\me\OneDrive\Desktop\code\js\my bot\node_modules\discord.js\src\util\BitField.js:168:11)
    at C:\Users\me\OneDrive\Desktop\code\js\my bot\node_modules\discord.js\src\util\BitField.js:163:54
    at Array.map (<anonymous>)
    at Function.resolve (C:\Users\me\OneDrive\Desktop\code\js\my bot\node_modules\discord.js\src\util\BitField.js:163:40)
    at Client._validateOptions (C:\Users\me\OneDrive\Desktop\code\js\my bot\node_modules\discord.js\src\client\Client.js:481:41)
    at new Client (C:\Users\me\OneDrive\Desktop\code\js\my bot\node_modules\discord.js\src\client\Client.js:78:10)
    at Object.<anonymous> (C:\Users\me\OneDrive\Desktop\code\js\my bot\index.js:3:16)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32) {
  [Symbol(code)]: 11
}
about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

In discord.js v14, intent flags are available from GatewayIntentBits.

const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({
  intents: [
    GatewayIntentBits.Guilds,
    GatewayIntentBits.GuildMessages,
    GatewayIntentBits.GuildPresences,
    GatewayIntentBits.GuildMembers,
    GatewayIntentBits.GuildMessageReactions,
  ],
});

List of changes:

v12/v13 v14
GUILDS GatewayIntentBits.Guilds
GUILD_BANS GatewayIntentBits.GuildBans
GUILD_EMOJIS_AND_STICKERS GatewayIntentBits.GuildEmojisAndStickers
GUILD_INTEGRATIONS GatewayIntentBits.GuildIntegrations
GUILD_INVITES GatewayIntentBits.GuildInvites
GUILD_MEMBERS GatewayIntentBits.GuildMembers
GUILD_MESSAGE_REACTIONS GatewayIntentBits.GuildMessageReactions
GUILD_MESSAGE_TYPING GatewayIntentBits.GuildMessageTyping
GUILD_MESSAGES GatewayIntentBits.GuildMessages
GUILD_PRESENCES GatewayIntentBits.GuildPresences
GUILD_SCHEDULED_EVENTS GatewayIntentBits.GuildScheduledEvents
GUILD_VOICE_STATES GatewayIntentBits.GuildVoiceStates
GUILD_WEBHOOKS GatewayIntentBits.GuildWebhooks
DIRECT_MESSAGES GatewayIntentBits.DirectMessages
DIRECT_MESSAGE_TYPING GatewayIntentBits.DirectMessageTyping
DIRECT_MESSAGE_REACTIONS GatewayIntentBits.DirectMessageReactions
N/A GatewayIntentBits.MessageContent
about 4 years ago · Santiago Gelvez Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda